package lee.study.TestDemo1023;

class Shape {
    public void draw() {

    }
}

class Cycle extends Shape {//圆形

    @Override
    public void draw() {
        super.draw();
        System.out.println("画一个⚪");
    }
}

class React extends Shape {//矩形

    @Override
    public void draw() {
        super.draw();
        System.out.println("画一个□");
    }
}

class Triangle extends Shape {//三角形


    @Override
    public void draw() {
        super.draw();
        System.out.println("画一个△");
    }
}

////////////////////////↑类的实现者//////////////////////////////////////
////////////////////////↓类的调用者//////////////////////////////////////
public class TestDemo1023 {
    public static void drawMap(Shape shape) {
        shape.draw();
    }

    public static void main(String[] args) {
        Shape shape1 = new Cycle();//向上转型
        Shape shape2 = new React();
        Shape shape3 = new Triangle();
        drawMap(shape1);
        drawMap(shape2);
        drawMap(shape3);
    }
}
